package org.example.config;

import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import lombok.Data;

/**
 * @author zengxiaoyu
 * @date 2025/9/12 10:49
 */
@Data
public class ExecutorConfig {

    private XxlJobConfig xxlJobConfig;
    private String appName;
    private String  title;
    private Integer port;
    private Integer jobGroupId;

    public ExecutorConfig(XxlJobConfig xxlJobConfig) {
        this.xxlJobConfig = xxlJobConfig;
    }

    public XxlJobSpringExecutor buildExecutor() {
        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
        xxlJobSpringExecutor.setAdminAddresses(xxlJobConfig.getAdminAddresses());
        xxlJobSpringExecutor.setAppname(appName);
        xxlJobSpringExecutor.setPort(port);
        xxlJobSpringExecutor.setAccessToken(xxlJobConfig.getAccessToken());
        return xxlJobSpringExecutor;
    }
}
